<?php

/**
 * Description of item_model
 *
 * @author Life Hazard
 */
class Item_Model extends Default_My_Model{
    
    public function __construct() {
        parent::__construct();
    }

    function custom_item_list($whr, $limit = 100, $offset = 0){
        return $this->db->query("SELECT master_item.*,p.nama_port FROM master_item join master_port p on p.id_port = master_item.id_port WHERE is_ready = 1 ".($whr ? " AND $whr " : "")." order by id_item LIMIT $limit OFFSET $offset");
    }
    
    function item_list($whr, $limit = 100, $offset = 0){
        return $this->db->query("SELECT master_item.*,p.nama_port FROM master_item join master_port p on p.id_port = master_item.id_port WHERE id_item <> 1 and is_ready = 1 ".($whr ? " AND $whr " : "")." order by id_item LIMIT $limit OFFSET $offset");
    }
    
    function count_item_list($whr){
        return $this->get_scalar("SELECT COUNT(id_item) as total FROM master_item join master_port p on p.id_port = master_item.id_port WHERE is_ready = 1 ".($whr ? " AND $whr " : ""), "total");
    }
    
}

?>
